<template>
  <div class="container">
    <div class="title">
      危化品企业监管
    </div>
    <div class="row1">
      <div v-for="(item, index) in row1List" :key="index">
        <img src="./imgs/r-2.png" alt="" />
        <div>{{ item.text }}</div>
        <div>
          完成 <span>{{ item.v1 }}</span
          >家
        </div>
        <div>
          未完成 <span>{{ item.v2 }}</span
          >家
        </div>
        <div>
          完成率 <span>{{ item.v3 }}</span
          >%
        </div>
      </div>
    </div>
    <div class="title">
      报警监测
    </div>
    <div class="row2">
      <div @click="leftClick"></div>
      <div ref="cont">
        <div v-for="(item, index) in row2List" :key="index" class="item">
          <div v-for="(j, k) in item" :key="k">
            <div>
              <span>{{ j.text }}</span>
              <span>{{ j.v0 }}</span>
            </div>
            <div>
              <div>
                比昨天<span>{{ j.v1 }}</span>
              </div>
              <div>
                已处置<span>{{ j.v2 }}</span>
              </div>
              <div>
                处置率<span>{{ j.v3 }}</span>
              </div>
            </div>
            <!--  -->
          </div>
        </div>
      </div>
      <div @click="rightClick"></div>
    </div>
    <div class="row3">
      <div>物联感知</div>
    </div>
    <div class="row4">
      <div v-for="(item, index) in row4List" :key="index">
        <div>
          {{ item.text }}
        </div>
        <div>
          <div :stlye="`width:${item.val}%`"></div>
        </div>
        <div>
          {{ item.val }}
        </div>
      </div>
    </div>
    <div class="row5">
      东营市危化品监测预警平台
    </div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  name: 'VehiclesRegistrationChart',
  data() {
    return {
      echartsInstance: null,
      qsData: ['东营区', '河口区', '垦利区', '利津县', '广饶县', '东营开发区'],
      hylData: [18000, 18000, 18000, 18000, 18000, 18000],
      row1List: [
        { text: '双重预防体系', v1: 259, v2: 3, v3: 98.9 },
        { text: '双重预防体系', v1: 259, v2: 3, v3: 98.9 },
        { text: '双重预防体系', v1: 259, v2: 3, v3: 98.9 }
      ],
      row4List: [
        { text: '智能视频识别', val: 466 },
        { text: '人员定位', val: 906 },
        { text: '加油站', val: 1003 }
      ],
      row2List: [
        [{ text: '今日报警数', v0: 2375, v1: 2342, v2: 179, v3: 7.53 }],
        [{ text: '累计报警数', v0: 2375, v1: 2342, v2: 179, v3: 7.53 }]
      ]
    }
  },
  mounted() {},
  beforeDestroy() {},
  created() {
    Math.easeInOutQuad = function(t, b, c, d) {
      t /= d / 2
      if (t < 1) return (c / 2) * t * t + b
      t--
      return (-c / 2) * (t * (t - 2) - 1) + b
    }
  },
  methods: {
    leftClick() {
      this.animateScroll(this.$refs.cont, -359)
    },
    rightClick() {
      this.animateScroll(this.$refs.cont, 359)
    },
    animateScroll(element, change) {
      const start = element.scrollLeft
      const increment = 20
      const duration = 500
      let currentTime = 0

      const animate = () => {
        currentTime += increment
        const val = Math.easeInOutQuad(currentTime, start, change, duration)
        element.scrollLeft = val
        if (currentTime < duration) {
          setTimeout(animate, increment)
        }
      }
      animate()
    }
  }
}
</script>

<style lang="scss" scoped>
.container {
  height: 100%;
  .title {
    width: 420px;
    height: 31px;
    background: url('./imgs/l-6.png') no-repeat center center / 100% 100%;
    font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
    font-weight: bold;
    font-size: 16px;
    color: #ffffff;
    line-height: 31px;
    text-align: left;
    font-style: normal;
    text-transform: none;
    padding-left: 20px;
    margin: 0px 0px 5px 0px;
  }
  .row1 {
    display: flex;
    justify-content: space-around;
    font-family: MicrosoftYaHeiUI;
    font-size: 16px;
    color: #ffffff;
    margin-bottom: 10px;
    & > div {
      width: 116px;
      height: 205px;
      background: url('./imgs/r-1.png') no-repeat;
      background-size: 100% 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      img {
        width: 103px;
        height: 86px;
        object-fit: contain;
      }
      & > :nth-child(2) {
        width: 100%;
        height: 30px;
        line-height: 30px;
        background: url('./imgs/r-5.png') no-repeat;
        background-size: 100% 100%;
        text-align: center;
      }
      & > :nth-child(3),
      :nth-child(4) {
        font-size: 14px;
        display: flex;
        align-items: center;
        span {
          font-family: YouSheBiaoTiHei;
          font-size: 24px;
          color: #16fdf5;
          margin: 0 5px 0 8px;
        }
      }
      & > :nth-child(5) {
        font-size: 14px;
        display: flex;
        align-items: center;
        span {
          font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
          font-weight: bold;
          font-size: 16px;
          color: #ff3e3e;
          margin: 0 5px 0 8px;
        }
      }
    }
  }
  .row2 {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    & > div:nth-child(1),
    & > div:nth-child(3) {
      width: 18px;
      height: 22px;
      background: url('./imgs/l-12.png') no-repeat;
      background-size: 100% 100%;
      cursor: pointer;
    }
    & > div:nth-child(3) {
      background: url('./imgs/l-18.png') no-repeat;
      background-size: 100% 100%;
    }
    & > div:nth-child(2) {
      font-family: MicrosoftYaHeiUI;
      font-size: 16px;
      color: #ffffff;
      display: flex;
      width: 359px;
      overflow: hidden;
      transition: all 0.5s;
      .item {
        min-width: 359px;
        & > div {
          width: 359px;
          height: 68px;
          padding: 2px 10px;
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          background: hsla(216, 62%, 50%, 0.2);
          border-radius: 4px 4px 4px 4px;
          border: 1px solid;
          border-image: radial-gradient(
              circle,
              rgba(106, 168, 251, 1),
              rgba(24, 120, 249, 1),
              rgba(24, 120, 249, 1),
              rgba(106, 168, 251, 1)
            )
            1 1;
          & > div:nth-child(1) {
            display: flex;
            align-items: center;
            & > span:nth-child(2) {
              font-family: YouSheBiaoTiHei;
              font-size: 24px;
              color: #ffde00;
              margin-left: 20px;
            }
          }
          & > div:nth-child(2) {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            height: 26px;
            background: url('./imgs/r-5.png') no-repeat;
            background-size: 100% 100%;
            & > div {
              display: flex;
              align-items: center;
              span {
                margin-left: 8px;
              }
            }
            & > div:nth-child(1) span {
              font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
              font-weight: bold;
              font-size: 18px;
              color: #18c624;
            }
            & > div:nth-child(2) {
              span {
                font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
                font-weight: bold;
                font-size: 18px;
                color: #ffde00;
              }
            }
            & > div:nth-child(3) span {
              font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
              font-weight: bold;
              font-size: 18px;
              color: hsla(0, 100%, 62%, 1);
            }
          }
        }
      }
    }
  }
  .row3 {
    display: flex;
    justify-content: space-between;
    & > div {
      width: 87px;
      height: 26px;
      background: url('./imgs/l-1.png') no-repeat center center / 100% 100%;
      font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
      font-weight: bold;
      font-size: 16px;
      color: #f6f9fe;
      text-align: center;
      font-style: normal;
      text-transform: none;
    }
    margin: 10px 0;
  }
  .row4 {
    display: flex;
    flex-direction: column;
    font-family: MicrosoftYaHeiUI;
    font-size: 16px;
    color: #f6f9fe;
    & > div {
      display: flex;
      align-items: center;
      // justify-content: space-between;
      & > div:nth-child(1) {
        width: 100px;
        text-align: right;
      }
      & > div:nth-child(2) {
        flex: 1;
        height: 10px;
        margin: 10px 5px;
        background: hsla(0, 0%, 100%, 0.2);
        border-radius: 5px 5px 5px 5px;
        & > div {
          height: 10px;
          background: linear-gradient(90deg, hsla(194, 100%, 64%, 1), hsla(214, 64%, 59%, 1));
          border-radius: 5px 5px 5px 5px;
        }
      }
      & > div:nth-child(3) {
        width: 60px;
        text-align: right;
      }
    }
  }
  .row5 {
    background: url('./imgs/r-6.png') no-repeat;
    width: 100%;
    height: 49px;
    line-height: 49px;
    text-align: center;
    background-size: 100% 100%;
    font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
    font-weight: bold;
    font-size: 20px;
    color: #ffffff;
    text-shadow: 4px 0px 0px hsla(0, 0%, 0%, 0.1);
    font-style: normal;
    text-transform: none;
    margin-top: 10px;
    cursor: pointer;
  }
}
</style>
